<?php
ob_start();
	include 'connect/connect.php';
  if(isset($_GET["khoa"])){
      mysql_query("update tbl_lop set f_trangthai='{$_GET["khoa"]}' WHERE f_lop='{$_GET['name']}'");
  }
  
		$result = mysql_query("SELECT * FROM tbl_lop order by f_malop DESC") or die(mysql_error()); 

	echo "<table border='1' style='border-collapse: collapse' width='900'>";
echo   '<td width="30" bgcolor="#D6E0D8">ID</td>
<td width="170" bgcolor="#D6E0D8">Tên lớp</td>
<td width="170" bgcolor="#D6E0D8">Loại hình</td>
<td width="170" bgcolor="#D6E0D8">Ngày bắt dầu</td>
<td width="270" bgcolor="#D6E0D8">Địa điểm học</td>
<td width="240" bgcolor="#D6E0D8">Phòng học</td>
<td width="100" bgcolor="#D6E0D8">Học sinh</td>	
<td width="100" bgcolor="#D6E0D8">Xóa</td>
<td width="100" bgcolor="#D6E0D8">Chuyển lớp</td>
<td width="100" bgcolor="#D6E0D8">Trạng thái</td>
';
		
    while ($row = mysql_fetch_array($result))
    {
	if($row['f_lop'] != 'none')
		{
				  echo "<tr>";
				  echo "<td>" . $row['f_malop'] . "</td>";
				  echo "<td>" . $row['f_lop'] . "</td>";			  
				  echo "<td>" . $row['f_loaihinh'] . "</td>";
				  echo "<td>" . $row['f_ngaybatdau'] . "</td>";
				  echo "<td>" . $row['f_diadiemhoc'] . "</td>";
				  echo "<td>" . $row['f_phonghoc'] . "</td>";
				  echo "<td><a href=hocvientronglop.php?name=".$row['f_lop'	].">Học viên</a></td>";
				  echo "<td><a href=delete.php?tt=3&id=" . $row['f_malop'] . ">Xóa</a></td>";
				  echo "<td><a href=#>Chuyển lớp</a></td>";
          if ($row['f_trangthai'] == 0) {
      echo "<td><a href=view.lop.php?name=" . $row['f_lop'] ."&khoa=1".">Chưa khóa</a></td>";
    }
    else {
      echo "<td><a href=view.lop.php?name=" . $row['f_lop'] ."&khoa=0". ">Đã khóa</a></td>";
    }
				  echo "</tr>";
		}
    }
	
echo "</table>";
echo "<p>";
echo 'Hom nay la '.date("d-m-y");
?>